$(function () {
    $(".manage-index-ttq-generate").live('click',function(){
        var _this = $(this);
        var section_code = _this.attr('data-code');
        art.dialog({
            content: '确定要更新这个区块吗？',
            ok: function () {
                var _ok = this;
                $.ajax({
                    url:MANAGE_TTQ['indexGenerate'],
                    type : 'POST',
                    dataType:'json',
                    data:{section_code:section_code},
                    beforeSend : function() {
                        art.dialog.Talert('<div id="message-loading">正在更新中ing...</div>',5,false);
                    },
                    success : function (data) {
                        if(data['status']==1){
                            _ok.close();
                            art.dialog.Talert('<div id="message-ok">'+data['message']+'</div>',1,false);
                            window.location.reload();
                        }else{
                            art.dialog.Talert('<div id="message-error">'+data['message']+'</div>',1,false);
                        }
                    }
                });
            },
            cancelVal: '关闭',
            cancel: true //为true等价于function(){}
        });
    });



    $(".manage-index-ttq-setting").live('click',function(){
        var _this = $(this);
        var section_code = _this.attr('data-code');
        var applybox = document.getElementById('manage_index_ttq_setting');
        art.dialog({
            zIndex: 10004,
            title: '涂涂圈设置区块',
            width: 400,
            height: 150,
            content: applybox,
            id: 'manage-index-ttq-setting-id',
            lock: true,
            okVal: '设置',
            ok: function () {
                var _ok = this;
                var num = $("#ManageTtqNum").val();
                var type = $("#ManageTtqType").val();
                $.ajax({
                    url:MANAGE_TTQ['indexTtqSetting'],
                    type : 'POST',
                    dataType:'json',
                    data:{section_code:section_code,num:num,type:type},
                    beforeSend : function() {
                        art.dialog.Talert('<div id="message-loading">正在设置中ing...</div>',5,false);
                    },
                    success : function (data) {
                        if(data['status']==1){
                            _ok.close();
                            art.dialog.Talert('<div id="message-ok">'+data['message']+'</div>',1,false);
                        }else{
                            art.dialog.Talert('<div id="message-error">'+data['message']+'</div>',1,false);
                        }
                    }
                });
            },
            cancelVal: '关闭',
            cancel: true //为true等价于function(){}
        });

    });

});